package com.code;

/**
 * Created by lucky on 2018/9/20.
 */
public class Sort {

    public static int[] insert_sort(int[] m){

        for (int j = 1 ; j <  m.length ; j ++){
            int key = m[j];

            int i = j-1;

            while(i >= 0 && m[i] < key){
                m[i + 1] = m[i];

                i = i - 1 ;
            }
            m[i + 1] = key;
        }
        return m ;
    }

    public static void main(String[] args) {
        int[] z = {3,5,2,7,6,8,9,1};
        int[] sort = insert_sort(z);
        for (int i = 0 ; i< sort.length ; i++){
            System.out.print(sort[i] + ",");
        }
    }
}
